<template>
  <div class="home">
    <div class="title">
      <img src="@/libs/images/guohui.png" />
      <span>温馨提示</span>
    </div>
    <div class="text">使用“无证入住登记”需向公安查询身份信息，服务费为<span>{{ money.chargeAmount }}元/次</span>。请准确填写个人身份信息。</div>
    <div class="btn" @click="jumpNewPage">已阅读，填写信息</div>
    <div class="logo">
      <img src="@/libs/images/logo.png" />
      <p>重庆公安旅业人证比对系统</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "home",
  data() {
    return {
      number: "",
      money: {
        chargeAmount: 0
      }
    };
  },
  methods: {
    // 获取服务费
    getMoneyInfo() {
      this.$api.system
        .queryChargeInfo()
        .then(res => {
          this.money = res;
        })
        .catch(err => {});
    },
    // 判断是否可访问
    getGuestExist(){
      let uId = sessionStorage.getItem("id");
      this.$api.system
        .queryGuestExist(this.number, uId)
        .then(res => {
          if (!res) {
            this.$router.push({ path: "/errors", query: { type: 1 } });
          }
        })
        .catch(err => {
          this.$router.push({ path: "/errors", query: { type: 2 } });
        });
    },
    // 跳转
    jumpNewPage() {
      this.$router.push({ path: "/info_entry", query: { optSn: this.number } });
    }
  },
  created() {
    let _this = this;
    _this.number = _this.$route.query.optSn;
    if (_this.$route.query.optSn) {
      _this.init(function() {
        _this.getGuestExist();
        _this.getMoneyInfo();
      });
    } else {
      _this.$router.push({ path: "/errors", query: { type: 2 } });
    }
  },
}
</script>

<style lang='less' scoped>
.home {
  background: #fff;
  height: 100vh;
  padding: 0 20px;
  text-align: center;
  .title {
    margin-top: 54px;
    margin-bottom: 24px;
    line-height: 22px;
    font-weight: bold;
    font-size: 20px;
    color: #333;
    img {
      width: 33px;
      height: 33px;
      vertical-align: -9px;
    }
    span {
      letter-spacing: 10px;
      margin-left: 10px;
    }
  }
  .text {
    margin: 0 auto;
    padding: 44px 0 33px;
    background: url("../libs/images/bj.png") no-repeat center center;
    background-size: auto 100%;
    width: 66%;
    min-width: 230px;
    line-height: 40px;
    text-align: left;
    letter-spacing: 5px;
    font-family: "Microsoft YaHei";
    font-weight: bold;
    font-size: 15px;
    color: #333;
    span {
      color: #ff6600;
    }
  }
  .btn {
    margin: 47px auto 0;
    background: #FF6600;
    height: 44px;
    line-height: 44px;
    font-weight: 400;
    font-size: 16px;
    color: #fff;
    border-radius: 3px;
  }
}
</style>
